<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace plugin\saiadmin\app\model\test;

use plugin\saiadmin\app\model\system\SystemUser;
use plugin\saiadmin\basic\BaseModel;

/**
 * 测试表模型
 */
class Test extends BaseModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 数据库表名称
     * @var string
     */
    protected $table = 'eb_system_test';

    protected $deleteTime = false;

    /**
     * 用户名 搜索
     */
    public function searchUsernameAttr($query, $value)
    {
        $query->where('username', 'like', '%'.$value.'%');
    }

    /**
     * 余额 搜索
     */
    public function searchMoneyAttr($query, $value)
    {
        $query->whereTime('money', 'between', $value);
    }


    /**
     * 关联模型user
     */
    public function user()
    {
        return $this->hasOne(SystemUser::class, 'user_id', 'id');
    }


}
